package com.cwj.juc;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author Chenwujie
 * 2021/6/24 21:20
 */

public class AtomicIntegerTest {
    public static void main(String[] args) {
        AtomicInteger atomicInteger = new AtomicInteger();
        int n = 0;
        for (int i = 0; i < 100; i++) {
            n += i;
            atomicInteger.accumulateAndGet(i, Integer::sum);
        }
        System.out.println("n ：" + n);
        System.out.println("atomic: " + atomicInteger);
    }
}
